//优惠券详情

let href=location.href;
console.log(href);

// 对url解码
href = decodeURI(href);
console.log(href);

// 分割url取id
var p_id = href.split("?")[1];
console.log(p_id);
var id = p_id.split("=")[1];
console.log(id);

var ulbox=document.querySelector("#product .info");

fetch("http://chst.vip:1234/api/getcouponproduct?couponid="+id).then(function(response){
    return response.json();
}).then(function(res){
    console.log(res);

    
    res.result.forEach(item => {
        console.log(item);

        var oli=document.createElement("li");
        oli.innerHTML=  `<a href="#">
                            <!-- 左边图片 -->
                            <div class="fl">
                                ${item.couponProductImg}
                            </div>
                            <!-- 右边文本 -->
                            <div class="infoR">
                                <div class="title">
                                    <h4>${item.couponProductName}</h4>
                                </div>
                                <div class="other">
                                    <h4 class="price">${item.couponProductPrice}</h4>
                                    <div class="mall">${item.couponProductTime}</div>
                                </div>
                            </div>
                        </a>`

                    ulbox.appendChild(oli);
    });
                   
                    console.log(ulbox);
   

})
